package main

import (
	"context"
	"flag"
	"fmt"
	"generate_grom_mode_and_dao/service/genertategrom/api/internal/serv"

	"generate_grom_mode_and_dao/service/genertategrom/api/internal/config"
	"generate_grom_mode_and_dao/service/genertategrom/api/internal/svc"

	"github.com/tal-tech/go-zero/core/conf"
	"github.com/tal-tech/go-zero/rest"
)

var configFile = flag.String("f", "service/genertategrom/api/etc/genertategrom.yaml", "the config file")

func main() {
	flag.Parse()

	//自己添加的
	//env := proc.Env("ENV_SERVER")
	//if env != "" {
	//	*configFile = "yaml/genertategorm-api-" + env + ".yaml"
	//}

	var c config.Config
	conf.MustLoad(*configFile, &c)

	ctx := svc.NewServiceContext(c)
	server := rest.MustNewServer(c.RestConf)
	defer server.Stop()

	service := serv.NewMakeService(context.Background(), ctx)
	err := service.Start()
	if nil != err {
		fmt.Println(err.Error())
		fmt.Printf("生成 model fail %s:%d...\n", c.Host, c.Port)
	} else {
		fmt.Printf("生成 model over %s:%d...\n", c.Host, c.Port)
	}

	//handler.RegisterHandlers(server, ctx)

	//fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
	//server.Start()
}
